home *** CD-ROM | disk | FTP | other *** search
- //***********************************************************************
- //
- // MainFrame.cpp
- //
- //***********************************************************************
-
- #define OEMRESOURCE
-
- #include <afxwin.h>
- #include <afxext.h>
- #include "Resource.h"
- #include "CLine.h"
- #include "Splitter.h"
- #include "MainFrame.h"
- #include "Paint6Doc.h"
- #include "TextView.h"
-
- IMPLEMENT_DYNCREATE (CMainFrame, CFrameWnd)
-
- BEGIN_MESSAGE_MAP (CMainFrame, CFrameWnd)
- ON_WM_CREATE ()
- ON_WM_MEASUREITEM ()
- ON_WM_DRAWITEM ()
- END_MESSAGE_MAP ()
-
- int CMainFrame::OnCreate (LPCREATESTRUCT lpcs)
- {
- if (CFrameWnd::OnCreate (lpcs) == -1)
- return -1;
-
- CMenu* pMenu = GetMenu ();
- for (int i=0; i<8; i++)
- pMenu->ModifyMenu (ID_COLOR_BLACK + i,
- MF_BYCOMMAND | MF_OWNERDRAW, ID_COLOR_BLACK + i);
- return 0;
- }
-
- BOOL CMainFrame::OnCreateClient (LPCREATESTRUCT lpcs,
- CCreateContext* pContext)
- {
- if (!m_wndSplitter1.CreateStatic (this, 1, 2) ||
- !m_wndSplitter1.CreateView (0, 0, RUNTIME_CLASS (CTextView),
- CSize (160, 0), pContext) ||
- !m_wndSplitter2.Create (&m_wndSplitter1, 2, 1, CSize (1, 1),
- pContext, WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
- SPLS_DYNAMIC_SPLIT, m_wndSplitter1.IdFromRowCol (0, 1)))
- return FALSE;
-
- return TRUE;
- }
-
- void CMainFrame::OnMeasureItem (int nIDCtl, LPMEASUREITEMSTRUCT lpmis)
- {
- lpmis->itemWidth = ::GetSystemMetrics (SM_CYMENU) * 4;
- lpmis->itemHeight = ::GetSystemMetrics (SM_CYMENU);
- }
-
- void CMainFrame::OnDrawItem (int nIDCtl, LPDRAWITEMSTRUCT lpdis)
- {
- BITMAP bm;
- CBitmap bitmap;
- bitmap.LoadOEMBitmap (OBM_CHECK);
- bitmap.GetObject (sizeof (bm), &bm);
-
- CDC dc;
- dc.Attach (lpdis->hDC);
-
- CBrush* pBrush = new CBrush (::GetSysColor ((lpdis->itemState &
- ODS_SELECTED) ? COLOR_HIGHLIGHT : COLOR_MENU));
- dc.FrameRect (&(lpdis->rcItem), pBrush);
- delete pBrush;
-
- if (lpdis->itemState & ODS_CHECKED) {
- CDC dcMem;
- dcMem.CreateCompatibleDC (&dc);
- CBitmap* pOldBitmap = dcMem.SelectObject (&bitmap);
-
- dc.BitBlt (lpdis->rcItem.left + 4, lpdis->rcItem.top +
- (((lpdis->rcItem.bottom - lpdis->rcItem.top) -
- bm.bmHeight) / 2), bm.bmWidth, bm.bmHeight, &dcMem,
- 0, 0, SRCCOPY);
-
- dcMem.SelectObject (pOldBitmap);
- }
-
- pBrush = new CBrush (CPaintDoc::m_crColors[lpdis->itemID -
- ID_COLOR_BLACK]);
- CRect rect = lpdis->rcItem;
- rect.DeflateRect (6, 4);
- rect.left += bm.bmWidth;
- dc.FillRect (rect, pBrush);
- delete pBrush;
-
- dc.Detach ();
- }
-